package com.zyx.springredispub.service;

import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author Yaxi.Zhang
 * @since 2022/3/30 23:41
 * desc: redis发布消息服务
 */
@Component
public class RedisService {
    @Resource
    private StringRedisTemplate stringRedisTemplate;

    public void sendMessage(String channel, String message) {
        // 发布消息
        stringRedisTemplate.convertAndSend(channel, message);
    }
}
